/*
 * Led.hpp
 *
 *  Created on: 04.06.2014
 *      Author: matti
 */

#ifndef LED_HPP_
#define LED_HPP_

#include "wiringPi.h"

/*
 * class for easy handling of LEDs.
 */
class Led {
private:
	//the pin the led is connected to
	const int PIN;
public:
	/*
	 * creates a new led, using the specified pin. will also configure the pin mode.
	 */
	Led(int p);
	/*
	 * returns true if the led is on.
	 */
	bool isOn() const;
	/*
	 * turns the led on.
	 */
	void on();
	/*
	 * turns the led off.
	 */
	void off();
	/*
	 * returns the pin the led is connected to.
	 */
	int getPin() const;
	/*
	 * turns the led on, waits "dur" milliseconds and turns it back off.
	 * note that this does not happen in its own thread, and therefore pauses the main thread until the delay is finished.
	 */
	void blink(int dur);
};

#endif /* LED_H_ */
